using SumerCoreDevOps.Shared.Enums;

namespace SumerCoreDevOps.Shared.Models.Messages;

/// <summary>
/// 工作流步骤下发消息
/// </summary>
public class WorkflowStepDispatchMessage
{
    /// <summary>
    /// 任务ID
    /// </summary>
    public long TaskId { get; set; }

    /// <summary>
    /// 步骤ID
    /// </summary>
    public long StepId { get; set; }

    /// <summary>
    /// 步骤类型
    /// </summary>
    public StepType StepType { get; set; }

    /// <summary>
    /// 步骤配置（JSON格式）
    /// </summary>
    public string StepConfig { get; set; } = null!;

    /// <summary>
    /// 执行命令
    /// </summary>
    public string? Command { get; set; }

    /// <summary>
    /// 工作目录
    /// </summary>
    public string WorkDirectory { get; set; } = null!;

    /// <summary>
    /// 超时时间（秒）
    /// </summary>
    public int TimeoutSeconds { get; set; }

    /// <summary>
    /// 重试策略
    /// </summary>
    public RetryPolicy? RetryPolicy { get; set; }

    /// <summary>
    /// 上下文变量
    /// </summary>
    public Dictionary<string, string> Context { get; set; } = [];

    /// <summary>
    /// 临时凭证（加密后）
    /// </summary>
    public Dictionary<CredentialType, string> EncryptedCredentials { get; set; } = [];
}

/// <summary>
/// 重试策略
/// </summary>
public class RetryPolicy
{
    /// <summary>
    /// 最大重试次数
    /// </summary>
    public int MaxRetries { get; set; }

    /// <summary>
    /// 重试间隔（秒）
    /// </summary>
    public int RetryIntervalSeconds { get; set; }
}
